package com.yzd.learnjava.reusing;

import com.yzd.learnjava.util.Print;

public class FinalOverridingIllusion extends WithFinals{
	public static void main(String[] args) {
		OverridingPrivate2 op2 = new OverridingPrivate2();
		op2.f();
		op2.g();
		
		OverridingPrivate op = op2;
		//op.f();//The method f() from the type OverridingPrivate is not visible
		//op.g();//The method f() from the type OverridingPrivate is not visible
		
		WithFinals wf = op2;
		//wf.f();//The method f() from the type OverridingPrivate is not visible
		//wf.g();//The method f() from the type OverridingPrivate is not visible
	}

}

class WithFinals{
	private final void f() {
		Print.print("WithFinals.f()");
	}
	
	private void g() {
		Print.print("WithFinal.g()");
	}
}

class OverridingPrivate extends WithFinals{
	private final void f() {
		Print.print("OverridingPrivate.f()");
	}
	
	private void g() {
		Print.print("OverridingPrivate.g()");
	}
}

class OverridingPrivate2 extends OverridingPrivate{
	public final void f() {
		Print.print("OverridingPrivate2.f()");
	}
	
	public void g() {
		Print.print("OverridingPrivate2.g()");
	}
}
